/**
 * @copyright 2015 Indie Semiconductor.
 *
 * This file is proprietary to Indie Semiconductor.
 * All rights reserved. Reproduction or distribution, in whole
 * or in part, is forbidden except by express written permission
 * of Indie Semiconductor.
 *
 * @file hwcfg.c
 */
#include "hwcfg.h"


uint8_t HWCFG_GetRCHFClockCalibValue(void)
{
        return 0x4A;
}

  
uint8_t HWCFG_GetRCLFClockCalibValue(void)
{
    return 0x12;
}


uint8_t HWCFG_GetRCClockCalibValue(void)
{
    return HWCFG_SFRS->CLOCK_CALIB_RC;
}

uint8_t HWCFG_Get32KClockCalibValue(void)
{
    return HWCFG_SFRS->CLOCK_CALIB_32K;
}

uint16_t HWCFG_GetVBG(void)
{
    uint32_t volt;
    
    if (HWCFG_SFRS->BANDGAP_VOLT == 0xFF)
        return E_HWCFG_ADC_VBG;

    volt =  (E_HWCFG_ADC_RANGE_FULL * 1000) / HWCFG_SFRS->BANDGAP_VOLT;
    return (uint16_t) volt;
}

uint8_t HWCFG_GetCalibrationVersion(void)
{
    return HWCFG_SFRS->CALIB_VERSION;
}

int16_t HWCFG_GetV2ICalibrationValue(CurrValue_t value)
{
    return 0x20;
}

int16_t HWCFG_GetLEDCalibrationValue(PwmChannel_t channel, CurrValue_t value)
{
//    if (value == CURR_30MA){
//        if ( HWCFG_SFRS->LED0_TRIM_30mA_25C <= 0x1FF){
//            return HWCFG_SFRS->LED0_TRIM_30mA_25C;
//        }else{
//            return 300; // 100uA*300 = 30mA
//        }
//    }else{
//        if ( HWCFG_SFRS->LED0_TRIM_6mA_25C <= 0x1FF){
//            return HWCFG_SFRS->LED0_TRIM_6mA_25C;
//        }else{
//            return 60; // 100uA*60 = 6mA
//        } 
//    }
    return 0x04; //27mA
}